package com.hariro.customview.pulltofresh;

import android.content.Context;
import android.util.AttributeSet;
import android.widget.LinearLayout;
import android.widget.ScrollView;

import com.android.volley.RequestQueue;
import com.android.volley.toolbox.Volley;
import com.nostra13.universalimageloader.core.DisplayImageOptions;
import com.nostra13.universalimageloader.core.ImageLoader;
import com.qianfeng.project.R;

public class CommodityScrollView extends ScrollView {

	private boolean initFlag = true;
	private LinearLayout first_commodityList;
	private LinearLayout second_commodityList;
	private ImageLoader imageLoader;
	private DisplayImageOptions options;
	private RequestQueue requestQueue;

	public CommodityScrollView(Context context) {
		super(context);
	}

	public CommodityScrollView(Context context, AttributeSet attrs) {
		super(context, attrs);
	}

	@Override
	protected void onScrollChanged(int l, int t, int oldl, int oldt) {
		super.onScrollChanged(l, t, oldl, oldt);
	}

	@Override
	protected void onLayout(boolean changed, int l, int t, int r, int b) {
		super.onLayout(changed, l, t, r, b);

		// 初始化
		if (changed && initFlag) {
			first_commodityList = (LinearLayout) findViewById(R.id.first_commodityList);
			second_commodityList = (LinearLayout) findViewById(R.id.second_commdityList);
			if (imageLoader == null) {
				imageLoader = ImageLoader.getInstance();
			}
			options = new DisplayImageOptions.Builder()
					.showStubImage(R.drawable.ic_launcher)// 加载等待 时显示的图片
					.showImageForEmptyUri(R.drawable.ic_launcher)// 加载数据为空时显示的图片
					.showImageOnFail(R.drawable.ic_launcher)// 加载失败时显示的图片
					.cacheInMemory().cacheOnDisc()
					/**
					 * .displayer(new RoundedBitmapDisplayer(20))
					 **/
					.build();
			requestQueue = Volley.newRequestQueue(getContext());
			initFlag = false;
		}
	}

	private void loadCommodityImage() {

	}
}
